<?php

namespace App\Controllers\v1;

use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use common\utils\SysCode;
use App\Controllers\BaseController;
use App\Services\UserService;
use App\Events\UserLogin;
use App\User;
use App\Services\MessageService;

class MessageController extends BaseController
{
//    public $allows = ['getlist'];//todo 调试去除

    //消息列表获取
    public function getlist(Request $request)
    {

        $type = $request->input("type", 0);
        $page = $request->get("page", 1);
        $pageSize = $request->get("page_size", 15);
        $result = MessageService::getlist(Auth::user(), $type, $page, $pageSize);
        return $result;
    }


    //更改消息状态
    public function changeStatus(Request $request)
    {
        $params = $request->input('id', 0);
        $id = explode(',', $params);
        return MessageService::msgChangestatus(Auth::user(), $id);
    }

    //删除消息
    public function delMessage(Request $request)
    {
        $params = $request->input('id', 0);
        $id = explode(',', $params);
        return MessageService::msgChangestatus(Auth::user(), $id, -1);
    }
}
